package it.slkfarm.adapter;

import android.R;
import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class SpinnerAdapter extends ArrayAdapter<String>
{
	/**
	 * @uml.property  name="inflater"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	private LayoutInflater inflater;
	/**
	 * @uml.property  name="strings" multiplicity="(0 -1)" dimension="1"
	 */
	private String[] strings;

	public SpinnerAdapter(Context context, int textViewResourceId, String[] objects) 
	{
		super(context, textViewResourceId, objects);
		inflater = LayoutInflater.from(context);
		strings = objects;
	}
	
	public View getDropDownView(int position, View convertView,ViewGroup parent) 
	{
        return getCustomView(position, convertView, parent);
    }
	
	public View getView(int position, View convertView, ViewGroup parent) 
	{
        return getCustomView(position, convertView, parent);
    }
	
	public View getCustomView(int position, View convertView, ViewGroup parent) 
	{	 
        View row = inflater.inflate(it.slkfarm.android.R.layout.spinner_item, parent, false);
        TextView label=(TextView)row.findViewById(it.slkfarm.android.R.id.tvSpinnerContent);
        label.setText(strings[position]);
        Typeface tf = Typeface.createFromAsset(this.getContext().getAssets(),"fonts/KMKDSP__.ttf");
        label.setTypeface(tf);
        return row;
    }
	
}
